package com.botann.projects.base;

import com.botann.projects.model.Role;
import com.botann.projects.model.AdminUser;
import com.botann.projects.model.Role;
import com.alibaba.fastjson.JSONObject;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import java.util.ArrayList;

/**
 * Created by liushanguo on 2017/5/19.
 */

@XmlRootElement(name = "Response")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({
        ArrayList.class,
        JSONObject.class,
        AdminUser.class,
        Role.class
})
public class Model{

    private Integer code;
    private String userInfo;
    private Object content;


    public Model(){}

    public Model(Integer code, String userInfo, Object content) {
        this.code = code;
        this.userInfo = userInfo;
        this.content = content;
    }

    public void put(String key,Object value){
        if (this.content != null && this.content instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) this.content;
            jsonObject.put(key,value);
        } else {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put(key,value);
            this.content = jsonObject;
        }
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getUserInfo() {
        return userInfo;
    }

    public void setUserInfo(String userInfo) {
        this.userInfo = userInfo;
    }

    public Object getContent() {
        return content;
    }

    public void setContent(Object content) {
        this.content = content;
    }
}
